<!-- right-->
<div class="MemberMain">
<div>

<script>
var prediv = '';
function showMsg(obj,msgid,url) {
  var currdiv = $('view_msg_pro_'+msgid);

  if(!obj.parentNode.id){
    if(typeof prediv == "object") {prediv.style.display='none'};
    currdiv.style.display = '';
	if($('view_msg_'+msgid))
    new Request.HTML({url:url,method:'post',update:'view_msg_'+msgid,data:''}).send();
    
    obj.parentNode.id = 'span_'+msgid;
    if(prediv){
      var link = $('span_'+prediv.id.substr(13)).getElementsByTagName('a')[0];
      link.className = 'viewmsgoff';
      toggleBg(link, false);
    }
    prediv = $('view_msg_pro_'+msgid);
    obj.className = 'viewmsg';
    toggleBg(obj, true);
  }else{
    if(currdiv.style.display == 'none'){
      currdiv.style.display = '';
      obj.className = 'viewmsg';
      toggleBg(obj, true);
      if(prediv) {
        prediv.style.display = 'none';
        var link = $('span_'+prediv.id.substr(13)).getElementsByTagName('a')[0];
        link.className = 'viewmsgoff';
        toggleBg(link, false);
      }
      prediv = currdiv;
    }else{
      currdiv.style.display = 'none';
      obj.className = 'viewmsgoff';
      toggleBg(obj, false);
      prediv = '';
    }
  }
}

function toggleBg(el, state){
  while(el.tagName != 'TR'){
    el = el.parentNode;
  }
  if(!state) $(el).removeClass('msgon');
  else $(el).addClass('msgon');
}

function checkAll(obj,box) {
  var tag = obj.getElementsByTagName('input');
  for(var i = 0;i < tag.length;i++){
    tag[i].checked = box.checked;
  }
}
</script>
<div id="demo1" class="section switch">
    <ul class="switchable-triggerBox">
        <li ><span><a href="<{link app=b2c ctl='site_member' act='comment'}>"><{t}>我的评论<{/t}></a></span></li>
        <li><a href="<{link app=b2c ctl='site_member' act='ask'}>"><{t}>我的咨询<{/t}></a></li>
        <li class="active" ><{t}>站内信<{/t}></li>
    </ul>
 <div class="switchable-content">
     <div class="switchable-panel">
            <!--<textarea class="textarea-lazyload">-->
              <div id="demo2" class="switch"style="padding-top:0" >
                <div class="site-mail">
                <ul class="switchable-triggerBox2 clearfix" >
                  <li ><a href="<{link app=b2c ctl='site_member' act='send'}>"><{t}>发送消息<{/t}></a></li>
                  <li class="active"><{t}>收件箱<{/t}><{if $inbox_num}><span>(<{$inbox_num}>)</span><{/if}></li>
                  <li><a href="<{link app=b2c ctl='site_member' act='track'}>"><{t}>发件箱<{/t}></a><span></span></li>
                  <li><a href="<{link app=b2c ctl='site_member' act='outbox'}>"><{t}>草稿箱<{/t}></a><{if $outbox_num}><span>(<{$outbox_num}>)</span><{/if}></li>
                  <li style="border:none"><a href="<{link app=b2c ctl='site_member' act='message'}>"><{t}>给管理员发短信<{/t}></a></li>
                </ul>
              </div>
              </div>
    </div>       
<div class="title"><{t}>收件箱<{/t}></div>
<form action="<{link app=b2c ctl='site_member' full='1' act='del_in_box_msg'}>" method="post" id="form_id">
<table width="100%" cellspacing="0" cellpadding="0" class="liststyle_option">
    <col class="span-0 textcenter"></col>
    <col class=" textleft"></col>

    <tr>
      <th class="textcenter"><input type="checkbox" onclick="checkAll(this.form,this)" name="chkall" id="chkall" title="<{t}>全选<{/t}>"></th>
            <td><input type="submit" value="<{t}>删除<{/t}>" name="pmsend /"></td>
            <td style="padding-right:10px; text-align:right"><{t}>共有短消息:<{/t}>&nbsp;<em id="pmtotalnum" class="siteparttitle-orage"><{$total_msg}></em></td>
    </tr>

    </table>
  <table width="100%" cellspacing="0" cellpadding="0"  summary="<{t}>收件箱<{/t}>" class="gridlist">
    <col class="span-0"></col>
    <col class="span-15"></col>
    <col class="span-2 "></col>
    <col class="span-3"></col>
    <col class="span-2"></col>
    <col class="span-2"></col>
    <thead>
      <tr>
        <th>&nbsp;</th>
        <th><{t}>标题<{/t}></th>
        <th ><{t}>来自<{/t}></th>
        <th ><{t}>时间<{/t}></th>
        <th ><{t}>操作<{/t}></th>
        <th ><{t}>是否阅读<{/t}></th>
      </tr>
    </thead>
    <tbody>
      <{if count($message)>0}>
       <{foreach item=msg from=$message}>
      <tr class="msgon">
        <td class="selector"><input type="checkbox" value=<{$msg.comment_id}> name="delete[]"></td>
        <td class="textleft">
          <span><a href="<{if $msg.unread}><{else}>#<{/if}>" onclick="showMsg(this,<{$msg.comment_id}>,'<{link app=b2c ctl='site_member' act='view_msg' arg0=$msg.comment_id }>');return false;" class="viewmsgoff"><{$msg.title|cut:60|nl2br}></a></span></td>
        <td align="center"><{$msg.author}></td>
        <td align="center"><{$msg.time|cdate:SDATE_STIME}></td>
        <td align="center"><span id="hui_<{$msg.comment_id}>" style="display:block" class="hui"><a href="#" <{if $msg.author_id==1}> onclick="Reply('<{link app=b2c ctl=site_member act=ajax_message arg0=$msg.comment_id arg1=reply}>',<{$msg.comment_id}>)";<{else}> onclick="Reply('<{link app=b2c ctl=site_member act=ajax_send arg0=$msg.comment_id arg1=reply}>',<{$msg.comment_id}>)";<{/if}>"  ><{t}>回复<{/t}></a></span>
        <span id="shou_<{$msg.comment_id}>" style="float:left;display:none" class="shou"><a href="#" onclick="shou(<{$msg.comment_id}>)"><{t}>收起回复<{/t}></a></span>	
        </td>
      
        <td style="text-align:center">
        <{if $msg.mem_read_status == 'true'}>
        <{t}>已读<{/t}>
        <{else}>
        <{t}>未读<{/t}>
        <{/if}>
        </th>
      </tr>
      <tr id="view_msg_pro_<{$msg.comment_id}>" style="display:none; white-space:normal;">
        <td class="memberviewinfo" colspan="6"><p id="view_msg_<{$msg.comment_id}>" style=" padding:10px 20px"></p></td>
      </tr>
      <!----------- -->
      
      
      
    <tr><td colspan="6"  style="border:none; background:none; overflow:hidden">  
<div id="reply_<{$msg.comment_id}>"class="division" style="display:none;">
</div>
   </td></tr>       
      
      
      
      
      
      
      
      <!----------- -->
      <{/foreach}>
      <{else}>
      <tr>
      <td height="60" colspan="6" class="ColColorWhite">
       <{t}> 收件箱内没有短信息。<{/t}>
      </td>
      </tr>
      <{/if}>
    </tbody>
    
  </table>
    <table width="100%" cellspacing="0" cellpadding="0" class="liststyle_option">
    <col class="span-0 textcenter"></col>
    <col class=" textleft"></col>

    <tr>
      <th class="textcenter"><input type="checkbox" onclick="checkAll(this.form,this)" name="chkall" id="chkall" title="<{t}>全选<{/t}>"></th>
            <td><input type="submit" value="<{t}>删除<{/t}>" name="pmsend /"></td>
            <td style="padding-right:10px; text-align:right"><{t}>共有短消息:<{/t}>&nbsp;<em id="pmtotalnum" class="siteparttitle-orage"><{$total_msg}></em></td>
    </tr>

    </table>
  <{pagers data=$pager}>
</form>


</div>
</div>
</div>

</div>
<!-- right-->

<script>
function Reply(url,msg_id){
	 var allshou = $ES('.shou');
	  allshou.each(function(cel,k){
	  	$$('.hui').setStyle('display','inline');
		if(cel.id != "shou_"+msg_id) {
			if( !$(cel).isDisplay() ) return;
			$(cel).setStyle('display','none');
			var _t = cel.id.split('_');
			if( _t[1] )
				shou(_t[1]);
			//alert($('hui_'+msg_id));
			//$('hui_'+msg_id).setStyle('display','inline');
			}
	  });
	  
	 var alltable = $ES('.send_table');
	  alltable.each(function(cel,k){
		//if(cel.id != "table_"+msg_id) cel.remove();
	  });
	new Request.HTML({url:url,method:'post',update:'reply_'+msg_id,data:''}).send();
	$('reply_'+msg_id).setStyle('display','inline');
	$('shou_'+msg_id).setStyle('display','block');
	$('hui_'+msg_id).setStyle('display','none');
               
              
}

function cha_form(author_id,obj){
	if(author_id){
		 $('form_id').action ="<{link app=b2c ctl=site_member act=msgtoadmin}>";
	}
	else{
		 $('form_id').action ="<{link app=b2c ctl=site_member act=send_msg}>";
	}
	if(obj.id == 'Submit') $('outbox_btn').value = 'true';
	else $('outbox_btn').value = 'false';
	 
}

function shou(msg_id){
	 $('shou_'+msg_id).setStyle('display','none');
	 $('hui_'+msg_id).setStyle('display','block');
	  $('reply_'+msg_id).setStyle('display','none');
	   $('table_'+msg_id).remove();
}
</script>
